#include "worker_pool.h"

static void test_work_func(work_t *self)
{
    ENTER();
    int num = (int)(self->arg);
    printf("hello, %d\n", num);
    sleep(3);
    work_destroy(&self);
    EXIT();
}

int worker_pool_test(void)
{
    printf("** worker pool test:\n");
    worker_pool_t *wp = worker_pool_new(3);
    assert(wp);

    uint32_t i = 0;
    while (1) {
        ++i;
        work_t *work = work_new((void *)i, test_work_func);
        assert(work);
        
        worker_pool_add(wp, work);
        sleep(2);
        
    }

    printf("** worker pool test success\n");
    
}
